package com.example.login.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.bean.GuanJianZiInfo;
import org.example.bean.PinglunInfo;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PingLunMapper {

    @Select("select * from pinglun where zhuangtai=1 limit #{start},5")
    List<PinglunInfo> findUserByPage(int start);

    @Select("select count(*) from pinglun where zhuangtai=1")
    int findUserAllCount();

    @Select("select * from tushu where tushuid=#{tushuid}")
    PinglunInfo finAllTushuId(int tushuid);

    @Update("update pinglun set zhuangtai=0 where tushuid=#{tushuid} ")
    void deletePingLun(int tushuid);

    @Insert("insert into guanjianzi values(null,#{neirong},1)")
    void savePingLun( String neirong);

    @Select("select * from guanjianzi where zhuangtai=1 limit #{start},5")
    List<GuanJianZiInfo>findAllGuanJianZi(int start);

    @Select("select count(*) from guanjianzi where zhuangtai=1")
    int findGuanCount();
}
